Feature: We can navigate the menu from the command line

  Scenario: When starting the application I should see the main menu 
    When I run XML Editor interactively
    And I close the stdin stream
    Then the output should contain "MAIN MENU"

  Scenario: When I enter the 'x' key in the main menu I get the exit dialog
    When I run XML Editor interactively
    And I type "x"
    And I close the stdin stream
    Then the output should contain "Do you really want to exit?"

  Scenario: When I enter the 'y' key in the exit dialog the application ends
    When I run XML Editor interactively
    And I type "x"
    And I type "y"
    And I type "n"
    And I close the stdin stream
    Then the output should contain "Do you really want to exit?"
    And the output should contain "XML editor closed."

  Scenario: When I enter the 'y' key in the exit dialog the application do not ends
    When I run XML Editor interactively
    And I type "x"
    And I type "n"
    And I close the stdin stream
    Then the output should contain "Do you really want to exit?"
    And the output should not contain "XML editor closed."

  Scenario: When I enter the '1' key in the main menu I get the new file dialog
    When I run XML Editor interactively
    And I type "1"
    And I close the stdin stream
    Then the output should contain "Please enter the path for the file"

  Scenario: When I enter a valid file name i get the file menu
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/correct_file_01.xml"
    And I close the stdin stream
    Then the output should contain "[input_files/correct_file_01.xml] successfully opened."
    And the output should contain "// input_files/correct_file_01.xml"
    And the output should contain "FILE MENU"

  Scenario: When I enter an invalid file name i do not get the file menu
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/no_such_file.xml"
    And I close the stdin stream
    Then the output should contain "! The file name you entered is not valid."
    And the output should not contain "[input_files/no_such_file.xml] successfully opened."
    And the output should not contain "// input_files/no_such_file.xml"
    And the output should not contain "FILE MENU"

  Scenario: When I enter the '2' key in the file menu I get the edit xml menu
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/correct_file_01.xml"
    And I type "2"
    And I close the stdin stream
    Then the output should contain "[input_files/correct_file_01.xml] successfully opened."
    And the output should contain "// input_files/correct_file_01.xml"
    And the output should contain "EDIT MENU"

  Scenario: When I enter the 'x' key in the edit menu I get the file menu
    When I run XML Editor interactively
    And I type "1"
    And I type "input_files/correct_file_01.xml"
    And I type "x"
    And I close the stdin stream
    Then the output should contain "[input_files/correct_file_01.xml] successfully opened."
    And the output should contain "// input_files/correct_file_01.xml"
    And the output should contain "FILE MENU"

  Scenario: When I enter the '2' key in the main menu I get the new file dialo
    When I run XML Editor interactively
    And I type "2"
    And I close the stdin stream
    Then the output should contain "Please enter the path for the new file:"

  Scenario: When I create a new file with an existing file name I get an error message
    When I run XML Editor interactively
    And I type "2"
    And I type "input_files/correct_file_01.xml"
    And I close the stdin stream
    Then the output should contain "Please enter the path for the new file:"
    And the output should contain "ERROR: file already exists. Choose another file name!"

  Scenario: When I create a new file from the main menu the file is created and in get the file menu
    When I launch XML Editor interactively
    And I type "2"
    And I type "new_file_test.xml"
    And I close the stdin stream
    Then the output should contain "Please enter the path for the new file:"
    And the output should contain "new_file_test.xml successfully created."
    And the output should contain "FILE MENU"
    And a file named "new_file_test.xml" should exist
